<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    function getTime(){
        var time = new Date();
        var h = time.getHours();
        if(h<10){
            h = '0' +h;
        }
        var m = time.getMinutes();
        if(m<10){
            m = '0' + m;
        }
        var s = time.getSeconds();
        if(s<10){
            s = '0' + s;
        }
        return h + ':' + m+':' + s ;
    }console.log(getTime());
    
    //获取日期的总的毫秒数（时间戳）  1970年1月1号开始
    //1.通过valueof()  getTime（）获取
    var date = new Date();
    console.log(date.valueOf());
    console.log(date.getTime());
    //简单的写法
    var date1 = +new Date();
    console.log(date1);
    //3.H5新增获得总毫秒数
    console.log(Date.now());
    

</script>
<body>
    
</body>
</html>